package logrus

import (
	"fmt"
	"github.com/sirupsen/logrus"
	"strings"
	"time"
)

type MyFormatter struct{}

func (s *MyFormatter) Format(entry *logrus.Entry) ([]byte, error) {
	timestamp := time.Now().Local().Format("2006/01/02 15:04:05")
	//msg := fmt.Sprintf("%s [%s] [%s:%d]  %s [%+v]  \n", timestamp, strings.ToUpper(entry.Level.String()),
	//	entry.Caller.File,entry.Caller.Line, entry.Message,entry.Data)

	// entry.Data 就是 WithFields 的固定参数
	msg := fmt.Sprintf("%s [%s] [%s:%d]  %s   \n", timestamp, strings.ToUpper(entry.Level.String()),
		entry.Caller.File, entry.Caller.Line, entry.Message)
	return []byte(msg), nil
}
